// /common/http.api.js

// 如果没有通过拦截器配置域名的话，可以在这里写上完整的URL(加上域名部分)
// let hotSearchUrl = '/ebapi/store_api/hot_search';
// let indexUrl = '/ebapi/public_api/index';

// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
const install = (Vue, vm) => {
	// 登录
	let login = (params = {}) => vm.$u.post('wxLogin', params);
	// 注册
	let register = (params = {}) => vm.$u.post('wxRegister', params);
	// 获取用户信息
	let getInfo = (params = {}) => vm.$u.get('getInfo', params);
	// 获取获取类别下拉树列表
	let getTreeSelect = () => vm.$u.get('/campus/commType/treeSelect');
	// 发布闲置
	let addCommodity = (params = {}) => vm.$u.post('/campus/commodity/addForWx', params);
	// 发布悬赏榜
	let addPriceList = (params = {}) => vm.$u.post('/campus/priceList/addForWx', params);
	// 查询商品
	let getCommodity = (params = {}) => vm.$u.get('/campus/commodity/listForWx', params);
	// 根据comId获取商品详情信息
	let getDetailByComId = (params = {}) => vm.$u.get('/campus/commodity/getDetailByComId', params);
	// 查询资讯
	let getInformation = (params = {}) => vm.$u.get('/campus/information/listForWx', params);
	// 根据imtId获取资讯详情信息
	let getDetailByImtId = (params = {}) => vm.$u.get('/campus/information/getDetailByImtId', params);
	// 查询Top3资讯
	let getTopThreeInformation = (params = {}) => vm.$u.get('/campus/information/getTopThreeInformation', params);
	// 根据comId和userId查询是否收藏该商品
	let checkIsCollect = (params = {}) => vm.$u.get('/campus/collect/checkIsCollect', params);
	// 收藏该商品
	let toCollect = (params = {}) => vm.$u.get('/campus/collect/toCollect', params);
	// 取消收藏该商品
	let cancelCollect = (params = {}) => vm.$u.get('/campus/collect/cancelCollect', params);
	// 新增评论
	let addComment = (params = {}) => vm.$u.post('/campus/comment/addForWx', params);
	// 根据comId查询评论列表
	let getCommentListByComId = (params = {}) => vm.$u.get('/campus/comment/selectCommentList', params);
	// 新增回复
	let addReplay = (params = {}) => vm.$u.post('/campus/reply/addForWx', params);
	// 根据cId获取留言板详细信息
	let getCommentByCId = (params = {}) => vm.$u.get('/campus/comment/getCommentByCId', params);
	// 根据cId获取评论信息
	let getReplyByCId = (params = {}) => vm.$u.get('/campus/reply/getReplyByCId', params);
	// 根据userId获取个人未读信息
	let getMessageByUserId = (params = {}) => vm.$u.get('/campus/comment/getMessageByUserId', params);
	// 根据cId和cuserId修改留言板回复信息的状态
	let updateReplyStatus = (params = {}) => vm.$u.get('/campus/reply/updateReplyStatus', params);
	// 查询个人收藏
	let selectMyCollectByUserId = (params = {}) => vm.$u.get('/campus/collect/selectMyCollectByUserId', params);
	// 查询个人闲置
	let selectMyCommodity = (params = {}) => vm.$u.get('/campus/commodity/selectMyCommodity', params);
	// 查询个人订单
	let selectMyOrder = (params = {}) => vm.$u.get('/campus/userOrder/selectMyOrder', params);
	// 评论订单
	let evaluateOrder =  (params = {}) => vm.$u.get('/campus/userOrder/evaluateOrder', params);
	// 创建订单
	let createOrder =  (params = {}) => vm.$u.post('/campus/userOrder/createOrder', params);
	// 取消订单
	let cancelOrder = (params = {}) => vm.$u.get('/campus/userOrder/cancelOrder', params);
	// 确认订单
	let finishOrder = (params = {}) => vm.$u.get('/campus/userOrder/finishOrder', params);
	// 得到悬赏榜列表
	let getPriceList = (params = {}) => vm.$u.get('/campus/priceList/getPriceList', params);
	// 申请领取悬赏榜
	let applyOffer = (params = {}) => vm.$u.post('/campus/apply/applyOffer', params);
	// 获取个人申请的悬赏榜id
	let getMyApplyOfferId = (params = {}) => vm.$u.get('/campus/apply/getMyApplyOfferId', params);
	// 获取个人要审核的悬赏榜信息
	let getMyAuditOffer = (params = {}) => vm.$u.get('/campus/apply/getMyAuditOffer', params);
	// 拒绝通过申请
	let refuseApply = (params = {}) => vm.$u.get('/campus/apply/refuseApply', params);
	// 同意通过申请
	let agreeApply = (params = {}) => vm.$u.get('/campus/apply/agreeApply', params);
	// 获取我申请的悬赏榜信息
	let getMyApplyOffer = (params = {}) => vm.$u.get('/campus/apply/getMyApplyOffer', params);
	// 获取我发布的悬赏榜
	let getMyPriceList = (params = {}) => vm.$u.get('/campus/priceList/getMyPriceList', params);
	
	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {
		login,
		register,
		getInfo,
		getTreeSelect,
		addCommodity,
		addPriceList,
		getCommodity,
		getDetailByComId,
		getInformation,
		getDetailByImtId,
		getTopThreeInformation,
		checkIsCollect,
		toCollect,
		cancelCollect,
		addComment,
		getCommentListByComId,
		addReplay,
		getCommentByCId,
		getReplyByCId,
		getMessageByUserId,
		updateReplyStatus,
		selectMyCollectByUserId,
		selectMyCommodity,
		selectMyOrder,
		evaluateOrder,
		createOrder,
		cancelOrder,
		finishOrder,
		getPriceList,
		applyOffer,
		getMyApplyOfferId,
		getMyAuditOffer,
		refuseApply,
		agreeApply,
		getMyApplyOffer,
		getMyPriceList,
	};
}

export default {
	install
}
